package com.ycy.query;

import com.ycy.BaseTest;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.engine.HistoryService;
import org.flowable.engine.history.HistoricActivityInstance;
import org.junit.Test;

import java.util.List;

public class ActiveQuery extends BaseTest {

  /**
   * 11. 历史
   * HistoricActivityInstance保存活动（流程中的节点）的一次执行的信息
   */
  @Test
  public void queryActivity() {
    HistoryService historyService = processEngine.getHistoryService();
    List<HistoricActivityInstance> activities =
            historyService.createHistoricActivityInstanceQuery().activityType("sequenceFlow")
                    .processInstanceId("2501")
                    .list();
    for (HistoricActivityInstance activity : activities) {
      System.out.println(activity);
    }
  }

  @Test
  public void query() {
    List<HistoricActivityInstance> startEvent =
            processEngine.getHistoryService().createHistoricActivityInstanceQuery()
                    .activityType("startEvent").processInstanceId("7504").list();
    for (HistoricActivityInstance historicActivityInstance : startEvent) {
      System.out.println(historicActivityInstance);
    }

  }

  @Test
  public void query1() {
    List<HistoricActivityInstance> list = historyService
            .createHistoricActivityInstanceQuery().processInstanceId("")
            .orderByHistoricActivityInstanceId().asc().list();
    for (HistoricActivityInstance historicActivityInstance : list) {
      System.out.println(historicActivityInstance);
    }

  }

}
